import { createRouter, createWebHashHistory } from 'vue-router'

const router = createRouter({
    history: createWebHashHistory(), // hash模式：createWebHashHistory，history模式：createWebHistory
    routes: [
        {
            path: '/',
            redirect: '/login'
        },
        {
            path: "/login",
            name:"登录",
            component: () => import("../views/Login.vue"),
            meta: {
                layout: 'empty' // 标记不需要布局
            }
        },
        {
            path: "/dashboard",
            name:"dashboard",
            component: () => import("../views/Dashboard.vue"),
        },
        {
            path: "/users",
            name:"邻里用户",
            component: () => import("../views/Users.vue"),
        },
        {
            path: "/products",
            name:"积分商城",
            component: () => import("../views/Products.vue"),
        },
        {
            path: "/orders",
            name:"积分订单",
            component: () => import("../views/Orders.vue"),
        },
        {
            path: "/posts",
            name:"社区动态",
            component: () => import("../views/Posts.vue"),
        },
        {
            path: "/admins",
            name:"管理员管理",
            component: () => import("../views/Admins.vue"),
        },
        {
            path: "/notification",
            name:"通知管理",
            component: () => import("../views/notification.vue"),
        },


        // {
        //     path: "/home",
        //     component: () => import("@/views/home.vue"),
        // },
        // {
        //     path: "/emp",
        //     component: () => import("@/views/emp.vue"),
        // },
        // {
        //     path: "/dept",
        //     component: () => import("@/views/dept.vue"),
        // }
    ]
})
router.beforeEach((to) => {
    // 目标页面是登录页 → 允许访问
    if (to.path === '/login') {
        return true;
    }
    // 目标页面不是登录页 → 这里可后续加登录判断（如token），暂时先允许访问
    // （当前你不需要存token，所以直接放行，后续有需求再加验证逻辑）
    return true;
})
export default router